<template>
  <div>
    <el-form ref="elForm" :model="ybssid" :rules="rules" size="medium" label-width="100px">
      <el-form-item label="社区" prop="belonging_Community">
        <el-input v-model="ybssid.belongingCommunity" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item label="街路巷" prop="street_RoadLan">
        <el-input v-model="ybssid.streetRoadLan" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item label="门牌号" prop="house_Number">
        <el-input v-model="ybssid.houseNumber" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item label="小区" prop="housing_Estate">
        <el-input v-model="ybssid.housingEstate" placeholder="" clearable :style="{width: '90%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="建筑物名称" prop="nameof_Buildings">
        <el-input v-model="ybssid.nameofBuildings" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item label="单元名称" prop="nameof_Theunit">
        <el-input v-model="ybssid.nameofTheunit" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item label="房间名称" prop="nameof_Theroom">
        <el-input v-model="ybssid.nameofTheroom" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item label="地址" prop="complete_Address">
        <el-input v-model="ybssid.completeAddress" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item label="户主名字" prop="house_hold_Names">
        <el-input v-model="ybssid.householdNames" clearable :style="{width: '90%'}"></el-input>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="updatafrom">保存</el-button>
        <el-button type="primary" @click="deletefrom">删除</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  import {updataList,deletefrom} from "@/api/address/userAddress";


  export default {
    name:"popup",
    components: {},
    props: {ybssid:null},
    data() {
      return {

      /*  ybssid: {
          belongingCommunity: undefined,
          streetRoadLan: undefined,
          houseNumber: undefined,
          housingEstate: undefined,
          nameofBuildings: undefined,
          nameofTheunit: undefined,
          nameofTheroom: undefined,
          completeAddress: undefined,
          householdNames: undefined,
        },*/
        rules: {
          belongingCommunity: [],
          streetRoadLan: [],
          houseNumber: [],
          housingEstate: [],
          nameofBuildings: [],
          nameofTheunit: [],
          nameofTheroom: [],
          completeAddress: [],
          householdNames: [],
        },
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {
      var str= this.ybssid.householdNames
      if(str!=null) {
        this.ybssid.householdNames = str.replace(str.slice(1, 2), '*')
      }
    },
    methods: {
      updatafrom(){
        var dataList=
        {
           ybssId:this.ybssid.ybssId,
           belongingCommunity :this.ybssid.belongingCommunity,
           streetRoadLan : this.ybssid.streetRoadLan,
           houseNumber : this.ybssid.houseNumber,
           housingEstate : this.ybssid.housingEstate,
           nameofBuildings : this.ybssid.nameofBuildings,
           nameofTheunit : this.ybssid.nameofTheunit,
           nameofTheroom : this.ybssid.nameofTheroom,
           completeAddress : this.ybssid.completeAddress,
           householdNames : this.ybssid.householdNames,
        }
        updataList(dataList).then(response=>{
          alert(response.msg)
        }).catch(err=> console.log(err))
      },
      deletefrom(){
        var ybssId=this.ybssid.ybssId
        deletefrom(ybssId).then(response=>{
          alert(response.msg)
        }).catch(err=>console.log(err))
      },
    }
  }

</script>
<style>
</style>
